package edu.gdkm.ssm.domain;

import edu.gdkm.ssm.utils.DateUtils;

import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 订单实体类
 */
public class Orders {

    private String id;
    private String orderNum;
    private Date orderTime;
    private String orderTimeStr;
    private Integer orderStatus;
    private String orderStatusStr;
    private int peopleCount;
    private Product product;
    private List<Traveller> travellers;
    private Member member;
    private Integer payType;
    private String payTypeStr;
    private String orderDesc;

    public String getId() {
        return id;
    }

    public String getOrderNum() {
        return orderNum;
    }

    public void setOrderNum(String orderNum) {
        this.orderNum = orderNum;
    }

    public Date getOrderTime() {
        return orderTime;
    }

    public String getOrderTimeStr() {
        if(orderTime != null){
            orderTimeStr= DateUtils.date2String(orderTime,"yyyy-MM-dd HH:mm");
        }
        return orderTimeStr;
    }

    public void setOrderTimeStr(String orderTimeStr) throws ParseException {
        if(orderTimeStr != null && !"".equals(orderTimeStr)){
            this.orderTime = DateUtils.string2Date(orderTimeStr, "yyyy-MM-dd HH:mm");
        }
        this.orderTimeStr = orderTimeStr;
    }

    public int getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(int orderStatus) {
        this.orderStatus = orderStatus;
    }

    public String getOrderStatusStr() {
        if(this.orderStatus != null){
            if(this.orderStatus == 0){
                this.orderStatusStr = "未支付";
            }else if(this.orderStatus == 1){
                this.orderStatusStr = "已支付";
            }
        }
        return orderStatusStr;
    }

    public void setOrderStatusStr(String orderStatusStr) {
        if(orderStatusStr != null && !"".equals(orderStatusStr)){
            if("未支付".equals(orderStatusStr)){
                this.orderStatus = 0;
            }else if("已支付".equals(orderStatusStr)){
                this.orderStatus = 1;
            }
        }
        this.orderStatusStr = orderStatusStr;
    }

    public int getPeopleCount() {
        return peopleCount;
    }

    public void setPeopleCount(int peopleCount) {
        this.peopleCount = peopleCount;
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public List<Traveller> getTravellers() {
        return travellers;
    }

    public void setTravellers(List<Traveller> travellers) {
        this.travellers = travellers;
    }

    public Member getMember() {
        return member;
    }

    public void setMember(Member member) {
        this.member = member;
    }

    public Integer getPayType() {
        return payType;
    }

    public void setPayType(Integer payType) {
        this.payType = payType;
    }

    public String getPayTypeStr() {
        if(payType != null){
            switch (payType){
                case 0:
                    this.payTypeStr = "支付宝";
                    break;
                case 1:
                    this.payTypeStr = "微信";
                    break;
                case 2:
                    this.payTypeStr = "其他";
                    break;
            }
        }
        return payTypeStr;
    }

    public void setPayTypeStr(String payTypeStr) {
        if(payTypeStr != null && !"".equals(payTypeStr)){
            switch (payTypeStr){
                case "支付宝":
                    this.payType = 0;
                    break;
                case "微信":
                    this.payType = 1;
                    break;
                case "其它":
                    this.payType = 2;
                    break;
            }
        }
        this.payTypeStr = payTypeStr;
    }

    public String getOrderDesc() {
        return orderDesc;
    }

    public void setOrderDesc(String orderDesc) {
        this.orderDesc = orderDesc;
    }
}
